package net.zjitc.stack;

import java.util.LinkedList;

public class StackByLinked<E> implements Mystack<E> {
    private LinkedList linkedList=new LinkedList();//创建双向链表LinkedList

    /**
     * 入栈
     * addLast()添加链表末端数值
     * @param e
     */
    @Override
    public void push(E e) {
        linkedList.addLast(e);
    }

    @Override
    public E pop() {
        return (E) linkedList.removeLast();
    }

    @Override
    public E peek() {
        return (E) linkedList.getLast();
    }

    @Override
    public boolean isEmpty() {
        return linkedList.isEmpty();
    }
}
